package com.santu.edu.supporter.biz.order.common.pojo.enums;

import com.santu.edu.supporter.exception.BizException;
import com.santu.edu.supporter.exception.CustomError;

/**
 * @author luoyaoqi
 * @createTime 2024/2/21
 * @description
 */
public enum OrderStatusEnum {
    /**
     *
     */
    TO_BE_PAID(0, "待支付"),
//    PAID(1, "已支付"),
//    WAITING(2, "待认领"),
    IN_PROGRESS(3, "进行中"),
    FINISHED(4, "已完成"),
    CANCEL(5, "已取消"),
    REFUNDING(6, "退款中"),
    REFUNDED(7, "已退款"),
    REFUND_FAILED(8, "退款失败"),;

    private Integer code;

    private String desc;

    OrderStatusEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }


    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public static OrderStatusEnum convert(Integer code) {
        for (OrderStatusEnum e : OrderStatusEnum.values()) {
            if (e.getCode().equals(code)) {
                return e;
            }
        }
        throw BizException.causeBy(CustomError.ENUM_CONVERT_ERROR,"TimeSectionType转换异常");
    }
}
